﻿using System;
using System.Collections.Generic;

namespace EduFormManager.Models
{
    public class Allform : Entity
    {
        public Allform()
        {
            Name = string.Empty;
            ExpireDate = DateTime.Now;
            FormQueries = new HashSet<Query>();
            EduOrgKinds = new HashSet<EduOrgKind>();
        }
        public virtual string Name { get; set; }
        public virtual DateTime ExpireDate { get; set; }
        public virtual ISet<EduFormData> EduFormData { get; set; }
        public virtual ISet<MunicipalityFormData> MunicipalityFormData { get; set; }
        public virtual ISet<Query> FormQueries { get; set; }
        public virtual byte[] CheckContents { get; set; }
        public virtual string CheckfileMD5 { get; set; }
        public virtual ISet<EduOrgKind> EduOrgKinds { get; set; }
        public virtual MunicipalitySummaryFormula SummaryFormula { get; set; }
        public virtual TemplatedFormData Template { get; set; }
        public virtual AllformType Type { get; set; }
        public virtual int DaysRemain
        {
            get
            {
                DateTime dateExpired = new DateTime(DateTime.Now.Year, ExpireDate.Month, ExpireDate.Day);
                DateTime dateNow = DateTime.Now;
                int daysRemaining = (dateExpired - dateNow).Duration().Days;
                return daysRemaining;
            }
        }
        public virtual MunicipalitySummaryFormula MunicipalitySummaryFormula { get; set; } 

        public override String ToString() {
            return this.Name;
        }
    }
}
